Also made the test buffer static inline for individual conversions like
it already was for fish paths.
Note, this relies on none of the tested conversions by accident
being buggy enough to modify their source data, adding a sanity
function that compares the buffers with the correct values could
perhaps be useful.
#define test_pixels 512
+
static double *
test_create (void)
{
- double *test;
- int i;
+ static double test[sizeof (double) * test_pixels * 4];
+ int i;
+ static int done = 0;
- srandom (20050728);
+ if (done)
+ return test;
- test = babl_malloc (sizeof (double) * test_pixels * 4);
+ srandom (20050728);
for (i = 0; i < test_pixels * 4; i++)
test [i] = (double) random () / RAND_MAX;
+
+ done = 1;
return test;
}
babl_free (destination_rgba_double);
babl_free (ref_destination);
babl_free (ref_destination_rgba_double);
- babl_free (test);
conversion->error = error;
conversion->cost = babl_process_cost (ticks_start, ticks_end);
{
static double test[sizeof (double) * NUM_TEST_PIXELS * 4];
int i, j;
+ static int done = 0;
+
+ if (done)
+ return test;
/* There is no need to generate the test
* more times ... */
for (j = 0; j < 16 * 4; i++, j++)
test [i] = 1.0 + (double) random () / RAND_MAX;
+ done = 1;
return test;
}